library(tidyverse)
library(mice)
library(skimr)
library(corrplot)
library(car)
library(ISLR)
library(ggplot2)
library(gridExtra)
library(SamplingStrata)
library(rbin)
library(leaps)
library(dplyr)
library(ggplot2)
library(geosphere)
library(broom)
library(plyr)
library(devtools)
options(scipen=999)

Objective 2 EDA:

nycraw <- read.csv("https://raw.githubusercontent.com/JaclynCoate/6372_Project/master/AB_NYC_2019.csv", header = TRUE, strip.white=TRUE)
head(nycraw)
##     id                                             name host_id
## 1 2539               Clean & quiet apt home by the park    2787
## 2 2595                            Skylit Midtown Castle    2845
## 3 3831                  Cozy Entire Floor of Brownstone    4869
## 4 5022 Entire Apt: Spacious Studio/Loft by central park    7192
## 5 5099        Large Cozy 1 BR Apartment In Midtown East    7322
## 6 5121                                  BlissArtsSpace!    7356
##     host_name neighbourhood_group      neighbourhood latitude longitude
## 1        John            Brooklyn         Kensington 40.64749 -73.97237
## 2    Jennifer           Manhattan            Midtown 40.75362 -73.98377
## 3 LisaRoxanne            Brooklyn       Clinton Hill 40.68514 -73.95976
## 4       Laura           Manhattan        East Harlem 40.79851 -73.94399
## 5       Chris           Manhattan        Murray Hill 40.74767 -73.97500
## 6       Garon            Brooklyn Bedford-Stuyvesant 40.68688 -73.95596
##         room_type price minimum_nights number_of_reviews last_review
## 1    Private room   149              1                 9    10/19/18
## 2 Entire home/apt   225              1                45     5/21/19
## 3 Entire home/apt    89              1               270      7/5/19
## 4 Entire home/apt    80             10                 9    11/19/18
## 5 Entire home/apt   200              3                74     6/22/19
## 6    Private room    60             45                49     10/5/17
##   reviews_per_month calculated_host_listings_count availability_365
## 1              0.21                              6              365
## 2              0.38                              2              355
## 3              4.64                              1              194
## 4              0.10                              1                0
## 5              0.59                              1              129
## 6              0.40                              1                0
str(nycraw)
## 'data.frame':    34464 obs. of  16 variables:
##  $ id                            : int  2539 2595 3831 5022 5099 5121 5178 5203 5238 5295 ...
##  $ name                          : Factor w/ 34000 levels ""," Private 1 bdrm Lefferts Gr, BK apt",..: 8990 27105 11178 13776 17775 5839 17808 11099 12643 3931 ...
##  $ host_id                       : int  2787 2845 4869 7192 7322 7356 8967 7490 7549 7702 ...
##  $ host_name                     : Factor w/ 9124 levels "","​ Valéria",..: 4017 3840 4984 4754 1544 2840 7735 5519 958 4836 ...
##  $ neighbourhood_group           : Factor w/ 5 levels "Bronx","Brooklyn",..: 2 3 2 3 3 2 3 3 3 3 ...
##  $ neighbourhood                 : Factor w/ 218 levels "Allerton","Arden Heights",..: 108 127 42 62 137 14 95 201 36 201 ...
##  $ latitude                      : num  40.6 40.8 40.7 40.8 40.7 ...
##  $ longitude                     : num  -74 -74 -74 -73.9 -74 ...
##  $ room_type                     : Factor w/ 3 levels "Entire home/apt",..: 2 1 1 1 1 2 2 2 1 1 ...
##  $ price                         : int  149 225 89 80 200 60 79 79 150 135 ...
##  $ minimum_nights                : int  1 1 1 10 3 45 2 2 1 5 ...
##  $ number_of_reviews             : int  9 45 270 9 74 49 430 118 160 53 ...
##  $ last_review                   : Factor w/ 908 levels "1/1/17","1/1/18",..: 113 575 775 175 671 144 677 745 716 671 ...
##  $ reviews_per_month             : num  0.21 0.38 4.64 0.1 0.59 0.4 3.47 0.99 1.33 0.43 ...
##  $ calculated_host_listings_count: int  6 2 1 1 1 1 1 1 4 1 ...
##  $ availability_365              : int  365 355 194 0 129 0 220 0 188 6 ...
nrow(nycraw)
## [1] 34464

EDA to determine type of multiple linear regression to perform

Determined that Times Square is a hot destination point. Used Lat long metrics to build a new metric with distance to Times Square

#Creating a new, tsquare_distance (distance to Times Square in miles)
for (i in 1:nrow(nycraw)) {
  n <- (distHaversine(c(nycraw$latitude[i], -nycraw$longitude[i]), c(40.7580, 73.9855)) / 1609.344)
  nycraw$tsquare_distance[i] <- n
}
head(nycraw)
##     id                                             name host_id
## 1 2539               Clean & quiet apt home by the park    2787
## 2 2595                            Skylit Midtown Castle    2845
## 3 3831                  Cozy Entire Floor of Brownstone    4869
## 4 5022 Entire Apt: Spacious Studio/Loft by central park    7192
## 5 5099        Large Cozy 1 BR Apartment In Midtown East    7322
## 6 5121                                  BlissArtsSpace!    7356
##     host_name neighbourhood_group      neighbourhood latitude longitude
## 1        John            Brooklyn         Kensington 40.64749 -73.97237
## 2    Jennifer           Manhattan            Midtown 40.75362 -73.98377
## 3 LisaRoxanne            Brooklyn       Clinton Hill 40.68514 -73.95976
## 4       Laura           Manhattan        East Harlem 40.79851 -73.94399
## 5       Chris           Manhattan        Murray Hill 40.74767 -73.97500
## 6       Garon            Brooklyn Bedford-Stuyvesant 40.68688 -73.95596
##         room_type price minimum_nights number_of_reviews last_review
## 1    Private room   149              1                 9    10/19/18
## 2 Entire home/apt   225              1                45     5/21/19
## 3 Entire home/apt    89              1               270      7/5/19
## 4 Entire home/apt    80             10                 9    11/19/18
## 5 Entire home/apt   200              3                74     6/22/19
## 6    Private room    60             45                49     10/5/17
##   reviews_per_month calculated_host_listings_count availability_365
## 1              0.21                              6              365
## 2              0.38                              2              355
## 3              4.64                              1              194
## 4              0.10                              1                0
## 5              0.59                              1              129
## 6              0.40                              1                0
##   tsquare_distance
## 1        2.2968748
## 2        0.1459679
## 3        2.2596886
## 4        2.9737754
## 5        0.7525852
## 6        2.4536331

Removing logically irrelevant variables

#Dropping logical irrelevant variables: "id", "name", "host_id", "host_name", "last_review", "latitude", "longitude", "neighborhood"
nyc2 <- select(nycraw, -c("id", "name", "host_id", "host_name", "last_review", "latitude", "longitude", "neighbourhood_group"))
head(nyc2)
##        neighbourhood       room_type price minimum_nights
## 1         Kensington    Private room   149              1
## 2            Midtown Entire home/apt   225              1
## 3       Clinton Hill Entire home/apt    89              1
## 4        East Harlem Entire home/apt    80             10
## 5        Murray Hill Entire home/apt   200              3
## 6 Bedford-Stuyvesant    Private room    60             45
##   number_of_reviews reviews_per_month calculated_host_listings_count
## 1                 9              0.21                              6
## 2                45              0.38                              2
## 3               270              4.64                              1
## 4                 9              0.10                              1
## 5                74              0.59                              1
## 6                49              0.40                              1
##   availability_365 tsquare_distance
## 1              365        2.2968748
## 2              355        0.1459679
## 3              194        2.2596886
## 4                0        2.9737754
## 5              129        0.7525852
## 6                0        2.4536331

Zero Value Variable Check

  • Checking on dependent variable range to make sure if there are zero’s to remove. It would not be free to stay in NYC.
  • Checking on independent variables that have ‘0’ as a value. Seeing that “availability_365” would mean the AirBnB isn’t available at all, we are dropping those from our data set.
nyc2 <- nyc2[!(nyc2$price==0),]
nyc2 <- nyc2[!(nyc2$availability_365==0),]
invisible(view(nyc2))

NA Evaluation and Drop

#Checking for NAs
md.pattern(nyc2)
##  /\     /\
## {  `---'  }
## {  O   O  }
## ==>  V <==  No need for mice. This data set is completely observed.
##  \  \|/  /
##   `-----'

##       neighbourhood room_type price minimum_nights number_of_reviews
## 25487             1         1     1              1                 1
##                   0         0     0              0                 0
##       reviews_per_month calculated_host_listings_count availability_365
## 25487                 1                              1                1
##                       0                              0                0
##       tsquare_distance  
## 25487                1 0
##                      0 0
nrow(nyc2)
## [1] 25487
#Drop NAs that are present
nyc3 <- na.omit(nyc2)
#Confirming NA drop
nrow(nyc3)
## [1] 25487

Storing all categorical variables as factors

#Storing categorical variables as factors
skim(nyc3)
## Skim summary statistics
##  n obs: 25487 
##  n variables: 9 
## 
## ── Variable type:factor ─────────────────────────────────────────────────────────────────────────────────────────────────────
##       variable missing complete     n n_unique
##  neighbourhood       0    25487 25487      217
##      room_type       0    25487 25487        3
##                                  top_counts ordered
##  Bed: 2172, Wil: 1739, Har: 1470, Bus: 1195   FALSE
##     Ent: 13363, Pri: 11472, Sha: 652, NA: 0   FALSE
## 
## ── Variable type:integer ────────────────────────────────────────────────────────────────────────────────────────────────────
##                        variable missing complete     n   mean     sd p0
##                availability_365       0    25487 25487 169.11 123.76  1
##  calculated_host_listings_count       0    25487 25487   6.98  32.08  1
##                  minimum_nights       0    25487 25487   6.23  16.8   1
##               number_of_reviews       0    25487 25487  38.94  54.8   1
##                           price       0    25487 25487 146.99 170.37 10
##  p25 p50 p75 p100     hist
##   52 157 290  365 ▇▅▂▃▂▃▃▆
##    1   1   3  327 ▇▁▁▁▁▁▁▁
##    1   2   4  999 ▇▁▁▁▁▁▁▁
##    5  17  51  629 ▇▁▁▁▁▁▁▁
##   69 107 175 8500 ▇▁▁▁▁▁▁▁
## 
## ── Variable type:numeric ────────────────────────────────────────────────────────────────────────────────────────────────────
##           variable missing complete     n mean   sd    p0  p25  p50  p75
##  reviews_per_month       0    25487 25487 1.85 1.81 0.02  0.49 1.29 2.73
##   tsquare_distance       0    25487 25487 3.44 3.07 0.016 1.48 2.69 4.26
##   p100     hist
##  58.5  ▇▁▁▁▁▁▁▁
##  18.86 ▇▇▂▁▁▁▁▁

Numerical v Numerical Multicollinearity

  • Multicollinearity will weaken the model
    • number_of_reviews and reviews_per_month are correlated at 55%
      • Removing reviews_per_month
corrNYC <- nyc3
#Table numeric variables
corrNYCTable <- corrNYC %>% keep(is.numeric) %>% cor %>% view
#Plot numeric variables v numeric variables
corrNYC %>% keep(is.numeric) %>% cor %>% corrplot("upper", addCoef.col = "white", number.digits = 2, number.cex = 0.5, method="square", order="hclust", tl.srt=45, tl.cex = 0.8)

invisible(view(corrNYCTable))
#Removing reviews_per_month due to high correlation of is and number_of_reviews
nyc4 <- select(nyc3, -c("reviews_per_month"))

Summary Review of Data Set

summary(nyc4)
##             neighbourhood             room_type         price     
##  Bedford-Stuyvesant: 2172   Entire home/apt:13363   Min.   :  10  
##  Williamsburg      : 1739   Private room   :11472   1st Qu.:  69  
##  Harlem            : 1470   Shared room    :  652   Median : 107  
##  Bushwick          : 1195                           Mean   : 147  
##  Hell's Kitchen    : 1171                           3rd Qu.: 175  
##  Upper East Side   :  867                           Max.   :8500  
##  (Other)           :16873                                         
##  minimum_nights    number_of_reviews calculated_host_listings_count
##  Min.   :  1.000   Min.   :  1.00    Min.   :  1.000               
##  1st Qu.:  1.000   1st Qu.:  5.00    1st Qu.:  1.000               
##  Median :  2.000   Median : 17.00    Median :  1.000               
##  Mean   :  6.233   Mean   : 38.94    Mean   :  6.981               
##  3rd Qu.:  4.000   3rd Qu.: 51.00    3rd Qu.:  3.000               
##  Max.   :999.000   Max.   :629.00    Max.   :327.000               
##                                                                    
##  availability_365 tsquare_distance  
##  Min.   :  1.0    Min.   : 0.01632  
##  1st Qu.: 52.0    1st Qu.: 1.47596  
##  Median :157.0    Median : 2.69428  
##  Mean   :169.1    Mean   : 3.44215  
##  3rd Qu.:290.0    3rd Qu.: 4.25571  
##  Max.   :365.0    Max.   :18.85560  
## 

Changing Price variable range

nyc4 <- filter(nyc4, price >= 25 & price <= 400)

Removing outliers from minimum nights stay

  • Anything over 365 is more than a year and would be improbable
  • Removing any minimum nights metric over 365
nyc4 <- nyc4[!(nyc4$minimum_nights > 365),]
invisible(view(nyc4))

Reviewing Linearity with Numeric Variables

  • Curved relationships with the numeric variables
    • Could require a quadratic or logarithmic transformation
#nyc4 %>% pairs() No color model
pairs(nyc4,col=nyc4$neighbourhood) #Color by neighborhood

Creating new Log price variable

  • Based on the above plots we may benefit from a transformation
    • Log transforming price to create a log-linear regression
log.nyc <- nyc4 %>% mutate(lprice=log(price))
log.nyc <- select(log.nyc, -c("price"))
invisible(log.nyc)

Reviewing Linearity with Log-Linear model: Independent and Logged Dependent (Price) Variable

  • Curved relationships with the numeric variables
    • Could require a quadratic or logarithmic transformation
pairs(log.nyc,col=log.nyc$neighbourhood)

Log-log model

  • Due to lack of linearity trying to transform the independent variables to see if we can surface a linear relationship
log.indep.nyc <- log.nyc %>% mutate(lreviews=log(number_of_reviews))
log.indep.nyc <- log.indep.nyc %>% mutate(lnights=log(minimum_nights))
log.indep.nyc <- log.indep.nyc %>% mutate(llistings=log(calculated_host_listings_count))
log.indep.nyc <- log.indep.nyc %>% mutate(lavailablility=log(availability_365))
log.indep.nyc <- log.indep.nyc %>% mutate(ltsqr=log(tsquare_distance))
invisible(log.indep.nyc)

log.indep.nyc <- select(log.indep.nyc, -c("minimum_nights", "number_of_reviews", "calculated_host_listings_count", "availability_365", "tsquare_distance"))
# Checking for -inf logged results
invisible(log.indep.nyc)
# Drop -inf log reults in lavailability
log.indep.nyc<-log.indep.nyc[!(log.indep.nyc$lavailablility=="-Inf"),]
invisible(log.indep.nyc)

Reviewing Linearity with Logged Independent and Dependent Variables

  • Curved relationships with the numeric variables
    • Could require a quadratic or logarithmic transformation
pairs(log.indep.nyc,col=log.indep.nyc$neighbourhood) #Color by neighborhood

Continuous Variable Bin Manipulation

  • Since we are seeing large clouds of data but no linear trend with logged and unlogged data, we are going to move forward with binning the data to see if it will assist us in determining if there is a relationship between the continuous variables and log price
nyc.bins <- nyc4

nyc.bins$reviewsBin <- var.bin(nyc.bins$number_of_reviews, bins = 50)
nyc.bins$nightsBin <- var.bin(nyc.bins$minimum_nights, bins = 50)
nyc.bins$availBin <- var.bin(nyc.bins$availability_365, bins = 50)
nyc.bins$listBin <- var.bin(nyc.bins$calculated_host_listings_count, bins = 10)
nyc.bins$tsquBin <- var.bin(nyc.bins$tsquare_distance, bins = 20)

nyc.bins <- select(nyc.bins,-c("minimum_nights", "number_of_reviews", "calculated_host_listings_count", "availability_365", "tsquare_distance"))
invisible(nyc.bins)

Reviewing Linearity with Binned Indepedent Variables

  • No linearity is presenting itself with a binned approach of the independent variables
nyc.bin.model <-lm(price~.,data=nyc.bins)
#nyc.bins  %>% pairs() No color model
pairs(nyc.bins,col=nyc.bins$neighbourhood) #Color by neighborhood

Explore potential correlation Neighborhood v Price

  • We have to this moment not be able to surface linearity relationships between our numerican independent varaibles and our dependentt variable
  • Next we will check for correltaion of the categorical variables: room_type & neighbourhood_group
  • We see a strong chance of correlation between Price and Neighbourhood Group
plot(nyc4$neighbourhood, nyc4$price, xlab = "Neighbourhood", ylab = "Price", title = "Price v Neighbourhood Correlation Check", col=c(7,32,52,82,107)) 

  • Narrowing down neighborhoods (randomly) to confirm neighbourhood is a significant categorical metrics to keep in MLR
nycNeighborhood <- ddply(nyc4,.(neighbourhood), function(x) x[sample(nrow(x),1),])

plot(nycNeighborhood$neighbourhood, nycNeighborhood$price, xlab = "Neighbourhood", ylab = "Price", title = "Price v Neighbourhood Correlation Check") 

Explore potential correlation Room Type v Price

  • We see a strong chance of corerlation between Price and Room Type
plot(nyc4$room_type, nyc4$price, xlab = "Room Type", ylab = "Price", title = "Price v Room Type Correlation Check", col=c(7,32,52)) 

Modeling

  • We are not seeing any linear correlation between the dependent and independent numeric varaibles
    • We have tried: linear regression, log-linear regression transformation, log-log regression transformation, binning, and outlier drop.
  • We are seeing a strong linear correlation between the dependent and independent categorical variables
  • We have surfaced the best residuals assumptions matched in a log-linear model
    • Due to these discoveries we are moving forward with a Two-Way ANOVA in order to create the strongest model
  • The number of Neighborhoods is so high deriving any sort of practical significance in a two-way ANOVA would be too difficult.
    • Changing our selected variables to Neighbourhod_Group and room_type

Clean data for Two-Way ANOVA

nyc.anova.raw <- read.csv("https://raw.githubusercontent.com/JaclynCoate/6372_Project/master/AB_NYC_2019.csv", header = TRUE, strip.white=TRUE)
head(nyc.anova.raw)
##     id                                             name host_id
## 1 2539               Clean & quiet apt home by the park    2787
## 2 2595                            Skylit Midtown Castle    2845
## 3 3831                  Cozy Entire Floor of Brownstone    4869
## 4 5022 Entire Apt: Spacious Studio/Loft by central park    7192
## 5 5099        Large Cozy 1 BR Apartment In Midtown East    7322
## 6 5121                                  BlissArtsSpace!    7356
##     host_name neighbourhood_group      neighbourhood latitude longitude
## 1        John            Brooklyn         Kensington 40.64749 -73.97237
## 2    Jennifer           Manhattan            Midtown 40.75362 -73.98377
## 3 LisaRoxanne            Brooklyn       Clinton Hill 40.68514 -73.95976
## 4       Laura           Manhattan        East Harlem 40.79851 -73.94399
## 5       Chris           Manhattan        Murray Hill 40.74767 -73.97500
## 6       Garon            Brooklyn Bedford-Stuyvesant 40.68688 -73.95596
##         room_type price minimum_nights number_of_reviews last_review
## 1    Private room   149              1                 9    10/19/18
## 2 Entire home/apt   225              1                45     5/21/19
## 3 Entire home/apt    89              1               270      7/5/19
## 4 Entire home/apt    80             10                 9    11/19/18
## 5 Entire home/apt   200              3                74     6/22/19
## 6    Private room    60             45                49     10/5/17
##   reviews_per_month calculated_host_listings_count availability_365
## 1              0.21                              6              365
## 2              0.38                              2              355
## 3              4.64                              1              194
## 4              0.10                              1                0
## 5              0.59                              1              129
## 6              0.40                              1                0
nyc.anova.raw2 <- select(nyc.anova.raw, -c("id", "name", "host_id", "host_name", "last_review", "latitude", "longitude", "neighbourhood", "minimum_nights", "number_of_reviews", "last_review", "reviews_per_month", "calculated_host_listings_count", "availability_365"))
head(nyc.anova.raw2)
##   neighbourhood_group       room_type price
## 1            Brooklyn    Private room   149
## 2           Manhattan Entire home/apt   225
## 3            Brooklyn Entire home/apt    89
## 4           Manhattan Entire home/apt    80
## 5           Manhattan Entire home/apt   200
## 6            Brooklyn    Private room    60
nyc.anova.raw2 <- filter(nyc.anova.raw2, price >= 25 & price <= 400)
invisible(view(nyc.anova.raw2))

Start 2-Way ANOVA Analysis

  • In completing this project with the tools learned in Unit 3 - we will perform a 2-Way ANOVA analysis.

Summary Statistics Table

  • Creating Mean, SD, SE, Min, Max, and IQR
  • Table of graphable statistics
nyc.anova <- nyc.anova.raw2

#Attaching the data set
attach(nyc.anova)
#Creating a function
nycsummary<-function(x){
  result<-c(length(x),mean(x),sd(x),sd(x)/sqrt(length(x)), min(x), max(x), IQR(x))
  names(result)<-c("N","Mean","SD","SE","Min","Max","IQR")
  return(result)
}
#Creating a summary stats table
nycsumstats<-aggregate(price~neighbourhood_group*room_type,data=nyc.anova,nycsummary)
nycsumstats<-cbind(nycsumstats[,1:2],nycsumstats[,-(1:2)])
nycsumstats
##    neighbourhood_group       room_type    N      Mean       SD         SE
## 1                Bronx Entire home/apt  298 114.47987 58.13523  3.3676835
## 2             Brooklyn Entire home/apt 7019 154.03733 67.74270  0.8085835
## 3            Manhattan Entire home/apt 7940 190.24181 74.32768  0.8341427
## 4               Queens Entire home/apt 1594 135.40088 65.71060  1.6458538
## 5        Staten Island Entire home/apt  145 118.80000 58.50411  4.8585017
## 6                Bronx    Private room  504  57.58929 26.98118  1.2018373
## 7             Brooklyn    Private room 7002  70.03870 32.59757  0.3895599
## 8            Manhattan    Private room 5455  99.57984 51.39588  0.6958745
## 9               Queens    Private room 2538  64.01418 29.55717  0.5867012
## 10       Staten Island    Private room  156  58.12179 27.52672  2.2039018
## 11               Bronx     Shared room   35  42.68571 25.20244  4.2599900
## 12            Brooklyn     Shared room  252  44.62302 29.90884  1.8840797
## 13           Manhattan     Shared room  317  71.03470 40.11323  2.2529837
## 14              Queens     Shared room  132  43.03030 19.56393  1.7028211
## 15       Staten Island     Shared room    3  85.00000 60.62178 35.0000000
##    Min Max   IQR
## 1   35 399 51.00
## 2   25 400 85.00
## 3   35 400 97.25
## 4   25 400 70.00
## 5   48 300 65.00
## 6   25 300 28.00
## 7   25 400 30.00
## 8   25 400 46.00
## 9   25 395 28.00
## 10  25 235 33.00
## 11  25 165 22.50
## 12  25 250 15.00
## 13  25 350 31.00
## 14  25 120 15.00
## 15  30 150 60.00

Summary Statistics Graph

#- The below graph shows characteristics of a nonadditive model #- Next Steps: # 1. Fit a non-additive model # 2. Check the assumptions # 3. Exmine Type III Sum of Squares F-test tables

ggplot(nycsumstats,aes(x=room_type,y=Mean,group=neighbourhood_group,colour=neighbourhood_group))+
  ylab("NYC AirBnBs Prices")+xlab("Room Type")+
  geom_line()+
  geom_point()+
  geom_errorbar(aes(ymin=Mean-SD,ymax=Mean+SD),width=.1)

Nonadditive 2-Way ANOVA

  • QQ Plot for assumption assessment
    • Show a curve, needs transformation
#The following code fits the nonadditive two way anova model and then produces the first the main residual diagnostics for assumption checking
nyc.model.fit<-aov(price~neighbourhood_group+room_type+neighbourhood_group:room_type,data=nyc.anova)

nyc.fits <- data.frame(fitted.values=nyc.model.fit$fitted.values,residuals=nyc.model.fit$residuals)

#Reisudals vs Fitted
nyc.plot1 <- ggplot(nyc.fits, aes(x=fitted.values,y=residuals))+ylab("Residuals")+
  xlab("Predicted")+geom_point()
#QQ Plot of residuals #Note the diagonal abline is only good for qqplots of normal data
nyc.plot2 <- ggplot(nyc.fits,aes(sample=residuals))+
  stat_qq()+geom_abline(intercept=mean(nyc.fits$residuals), slope = sd(nyc.fits$residuals))
#Histograms of residuals
nyc.plot3 <- ggplot(nyc.fits, aes(x=residuals)) + 
  geom_histogram(aes(y=..density..),binwidth=1,color="black", fill="gray")+
  geom_density(alpha=.1, fill="red")
#Grid of all 3 graphs above
grid.arrange(nyc.plot1, nyc.plot2, nyc.plot3, ncol=3)

par(mfrow=c(2,2))
plot(nyc.model.fit)

Log transformation on price

#Transforming price to logged variable
nyc.log.anova <- nyc.anova %>% mutate(lprice=log(price))
#view(nyc.final)

Assumptions check on log transformation of price

  • Equal variances: there is some slight variation of variances but this will suffice in order to move forward
  • QQ Plot: there is still some slight departure from normality, but again this is acceptable to move forward with our model
  • DON’T FORGET TO MENTION CLT - Central Limit Theorum
nyc.model.fit.log<-aov(lprice~neighbourhood_group+room_type+neighbourhood_group:room_type,data=nyc.log.anova)

nyc.fits.log <- data.frame(fitted.values=nyc.model.fit.log$fitted.values,residuals=nyc.model.fit.log$residuals)

#Reisudals vs Fitted
nyc.logplot1 <- ggplot(nyc.fits.log, aes(x=fitted.values,y=residuals))+ylab("Residuals")+
  xlab("Predicted")+geom_point()
#QQ Plot of residuals #Note the diagonal abline is only good for qqplots of normal data
nyc.logplot2 <- ggplot(nyc.fits.log,aes(sample=residuals))+
  stat_qq()+geom_abline(intercept=mean(nyc.fits.log$residuals), slope = sd(nyc.fits.log$residuals))
#Histograms of residuals
nyc.logplot3 <- ggplot(nyc.fits.log, aes(x=residuals)) + 
  geom_histogram(aes(y=..density..),binwidth=1,color="black", fill="gray")+
  geom_density(alpha=.1, fill="red")
#Grid of all 3 graphs above
grid.arrange(nyc.logplot1, nyc.logplot2, nyc.logplot3, ncol=3)

par(mfrow=c(2,2))

plot(nyc.model.fit.log)

Outliers

  • Since there are not singular points that are aggressively skewing the data, these outliers aren’t considered unique or affecting the model in a way that would not be logical.
  • Choose to leave all low and high end metrics since the model should take these into account

Type III F-test table

  • From the below F-test table we can see that neighborhood_group, room_type, as well as their interaction are all statistically significant for this model
  • The type-3 sums of squares F-test is provided below. The test for an interaction is not significant (F-stat: 12.493 p-value < .0001). Therefore, we can conclude that the potential changes in AirBnB price for one of the factors does depend on the other.
Anova(nyc.model.fit, type = 3)
## Anova Table (Type III tests)
## 
## Response: price
##                                  Sum Sq    Df  F value
## (Intercept)                     3905481     1 1187.124
## neighbourhood_group             8194094     4  622.677
## room_type                        649678     2   98.739
## neighbourhood_group:room_type    529559     8   20.121
## Residuals                     109799287 33375         
##                                              Pr(>F)    
## (Intercept)                   < 0.00000000000000022 ***
## neighbourhood_group           < 0.00000000000000022 ***
## room_type                     < 0.00000000000000022 ***
## neighbourhood_group:room_type < 0.00000000000000022 ***
## Residuals                                              
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Anova(nyc.model.fit.log,type=3)
## Anova Table (Type III tests)
## 
## Response: lprice
##                               Sum Sq    Df   F value                Pr(>F)
## (Intercept)                   6420.9     1 39324.029 < 0.00000000000000022
## neighbourhood_group            350.2     4   536.194 < 0.00000000000000022
## room_type                       93.4     2   286.105 < 0.00000000000000022
## neighbourhood_group:room_type   27.4     8    20.988 < 0.00000000000000022
## Residuals                     5449.6 33375                                
##                                  
## (Intercept)                   ***
## neighbourhood_group           ***
## room_type                     ***
## neighbourhood_group:room_type ***
## Residuals                        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Confidence Intervals for F Test
confint(nyc.model.fit.log)
##                                                              2.5 %
## (Intercept)                                             4.59597020
## neighbourhood_groupBrooklyn                             0.26099010
## neighbourhood_groupManhattan                            0.48444255
## neighbourhood_groupQueens                               0.11454831
## neighbourhood_groupStaten Island                       -0.04476596
## room_typePrivate room                                  -0.72145305
## room_typeShared room                                   -1.13046074
## neighbourhood_groupBrooklyn:room_typePrivate room      -0.17638784
## neighbourhood_groupManhattan:room_typePrivate room     -0.06971507
## neighbourhood_groupQueens:room_typePrivate room        -0.12053167
## neighbourhood_groupStaten Island:room_typePrivate room -0.14684224
## neighbourhood_groupBrooklyn:room_typeShared room       -0.42930871
## neighbourhood_groupManhattan:room_typeShared room      -0.17555003
## neighbourhood_groupQueens:room_typeShared room         -0.28983872
## neighbourhood_groupStaten Island:room_typeShared room   0.07160305
##                                                              97.5 %
## (Intercept)                                             4.687730749
## neighbourhood_groupBrooklyn                             0.354678302
## neighbourhood_groupManhattan                            0.577909184
## neighbourhood_groupQueens                               0.214518934
## neighbourhood_groupStaten Island                        0.115622772
## room_typePrivate room                                  -0.605701211
## room_typeShared room                                   -0.847423174
## neighbourhood_groupBrooklyn:room_typePrivate room      -0.057584148
## neighbourhood_groupManhattan:room_typePrivate room      0.049341540
## neighbourhood_groupQueens:room_typePrivate room         0.005806175
## neighbourhood_groupStaten Island:room_typePrivate room  0.069461684
## neighbourhood_groupBrooklyn:room_typeShared room       -0.128601673
## neighbourhood_groupManhattan:room_typeShared room       0.121673124
## neighbourhood_groupQueens:room_typeShared room          0.027483150
## neighbourhood_groupStaten Island:room_typeShared room   1.037936956

Multiple Test Technique on No Transformation: Tukey-Kramer

  • From the F-test table we can see that all current variables are statistically significnat at the 0.05 alpha level
  • Move forward with the Tukey-Kramer to discover what factors and/or combinations contribute to predicting the price of a NYC AirBnB
nyc.anova.diff <- TukeyHSD(nyc.model.fit,"neighbourhood_group:room_type", conf.level = .95)
nyc.anova.diff
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = price ~ neighbourhood_group + room_type + neighbourhood_group:room_type, data = nyc.anova)
## 
## $`neighbourhood_group:room_type`
##                                                                  diff
## Brooklyn:Entire home/apt-Bronx:Entire home/apt             39.5574615
## Manhattan:Entire home/apt-Bronx:Entire home/apt            75.7619478
## Queens:Entire home/apt-Bronx:Entire home/apt               20.9210125
## Staten Island:Entire home/apt-Bronx:Entire home/apt         4.3201342
## Bronx:Private room-Bronx:Entire home/apt                  -56.8905801
## Brooklyn:Private room-Bronx:Entire home/apt               -44.4411625
## Manhattan:Private room-Bronx:Entire home/apt              -14.9000308
## Queens:Private room-Bronx:Entire home/apt                 -50.4656814
## Staten Island:Private room-Bronx:Entire home/apt          -56.3580709
## Bronx:Shared room-Bronx:Entire home/apt                   -71.7941515
## Brooklyn:Shared room-Bronx:Entire home/apt                -69.8568499
## Manhattan:Shared room-Bronx:Entire home/apt               -43.4451655
## Queens:Shared room-Bronx:Entire home/apt                  -71.4495627
## Staten Island:Shared room-Bronx:Entire home/apt           -29.4798658
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt         36.2044863
## Queens:Entire home/apt-Brooklyn:Entire home/apt           -18.6364490
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt    -35.2373273
## Bronx:Private room-Brooklyn:Entire home/apt               -96.4480415
## Brooklyn:Private room-Brooklyn:Entire home/apt            -83.9986240
## Manhattan:Private room-Brooklyn:Entire home/apt           -54.4574922
## Queens:Private room-Brooklyn:Entire home/apt              -90.0231429
## Staten Island:Private room-Brooklyn:Entire home/apt       -95.9155324
## Bronx:Shared room-Brooklyn:Entire home/apt               -111.3516130
## Brooklyn:Shared room-Brooklyn:Entire home/apt            -109.4143114
## Manhattan:Shared room-Brooklyn:Entire home/apt            -83.0026269
## Queens:Shared room-Brooklyn:Entire home/apt              -111.0070242
## Staten Island:Shared room-Brooklyn:Entire home/apt        -69.0373273
## Queens:Entire home/apt-Manhattan:Entire home/apt          -54.8409353
## Staten Island:Entire home/apt-Manhattan:Entire home/apt   -71.4418136
## Bronx:Private room-Manhattan:Entire home/apt             -132.6525279
## Brooklyn:Private room-Manhattan:Entire home/apt          -120.2031104
## Manhattan:Private room-Manhattan:Entire home/apt          -90.6619786
## Queens:Private room-Manhattan:Entire home/apt            -126.2276292
## Staten Island:Private room-Manhattan:Entire home/apt     -132.1200187
## Bronx:Shared room-Manhattan:Entire home/apt              -147.5560993
## Brooklyn:Shared room-Manhattan:Entire home/apt           -145.6187977
## Manhattan:Shared room-Manhattan:Entire home/apt          -119.2071133
## Queens:Shared room-Manhattan:Entire home/apt             -147.2115106
## Staten Island:Shared room-Manhattan:Entire home/apt      -105.2418136
## Staten Island:Entire home/apt-Queens:Entire home/apt      -16.6008783
## Bronx:Private room-Queens:Entire home/apt                 -77.8115926
## Brooklyn:Private room-Queens:Entire home/apt              -65.3621751
## Manhattan:Private room-Queens:Entire home/apt             -35.8210433
## Queens:Private room-Queens:Entire home/apt                -71.3866939
## Staten Island:Private room-Queens:Entire home/apt         -77.2790834
## Bronx:Shared room-Queens:Entire home/apt                  -92.7151640
## Brooklyn:Shared room-Queens:Entire home/apt               -90.7778624
## Manhattan:Shared room-Queens:Entire home/apt              -64.3661780
## Queens:Shared room-Queens:Entire home/apt                 -92.3705753
## Staten Island:Shared room-Queens:Entire home/apt          -50.4008783
## Bronx:Private room-Staten Island:Entire home/apt          -61.2107143
## Brooklyn:Private room-Staten Island:Entire home/apt       -48.7612968
## Manhattan:Private room-Staten Island:Entire home/apt      -19.2201650
## Queens:Private room-Staten Island:Entire home/apt         -54.7858156
## Staten Island:Private room-Staten Island:Entire home/apt  -60.6782051
## Bronx:Shared room-Staten Island:Entire home/apt           -76.1142857
## Brooklyn:Shared room-Staten Island:Entire home/apt        -74.1769841
## Manhattan:Shared room-Staten Island:Entire home/apt       -47.7652997
## Queens:Shared room-Staten Island:Entire home/apt          -75.7696970
## Staten Island:Shared room-Staten Island:Entire home/apt   -33.8000000
## Brooklyn:Private room-Bronx:Private room                   12.4494175
## Manhattan:Private room-Bronx:Private room                  41.9905493
## Queens:Private room-Bronx:Private room                      6.4248987
## Staten Island:Private room-Bronx:Private room               0.5325092
## Bronx:Shared room-Bronx:Private room                      -14.9035714
## Brooklyn:Shared room-Bronx:Private room                   -12.9662698
## Manhattan:Shared room-Bronx:Private room                   13.4454146
## Queens:Shared room-Bronx:Private room                     -14.5589827
## Staten Island:Shared room-Bronx:Private room               27.4107143
## Manhattan:Private room-Brooklyn:Private room               29.5411318
## Queens:Private room-Brooklyn:Private room                  -6.0245188
## Staten Island:Private room-Brooklyn:Private room          -11.9169084
## Bronx:Shared room-Brooklyn:Private room                   -27.3529889
## Brooklyn:Shared room-Brooklyn:Private room                -25.4156874
## Manhattan:Shared room-Brooklyn:Private room                 0.9959971
## Queens:Shared room-Brooklyn:Private room                  -27.0084002
## Staten Island:Shared room-Brooklyn:Private room            14.9612968
## Queens:Private room-Manhattan:Private room                -35.5656506
## Staten Island:Private room-Manhattan:Private room         -41.4580401
## Bronx:Shared room-Manhattan:Private room                  -56.8941207
## Brooklyn:Shared room-Manhattan:Private room               -54.9568191
## Manhattan:Shared room-Manhattan:Private room              -28.5451347
## Queens:Shared room-Manhattan:Private room                 -56.5495320
## Staten Island:Shared room-Manhattan:Private room          -14.5798350
## Staten Island:Private room-Queens:Private room             -5.8923895
## Bronx:Shared room-Queens:Private room                     -21.3284701
## Brooklyn:Shared room-Queens:Private room                  -19.3911685
## Manhattan:Shared room-Queens:Private room                   7.0205159
## Queens:Shared room-Queens:Private room                    -20.9838814
## Staten Island:Shared room-Queens:Private room              20.9858156
## Bronx:Shared room-Staten Island:Private room              -15.4360806
## Brooklyn:Shared room-Staten Island:Private room           -13.4987790
## Manhattan:Shared room-Staten Island:Private room           12.9129054
## Queens:Shared room-Staten Island:Private room             -15.0914918
## Staten Island:Shared room-Staten Island:Private room       26.8782051
## Brooklyn:Shared room-Bronx:Shared room                      1.9373016
## Manhattan:Shared room-Bronx:Shared room                    28.3489860
## Queens:Shared room-Bronx:Shared room                        0.3445887
## Staten Island:Shared room-Bronx:Shared room                42.3142857
## Manhattan:Shared room-Brooklyn:Shared room                 26.4116844
## Queens:Shared room-Brooklyn:Shared room                    -1.5927128
## Staten Island:Shared room-Brooklyn:Shared room             40.3769841
## Queens:Shared room-Manhattan:Shared room                  -28.0043973
## Staten Island:Shared room-Manhattan:Shared room            13.9652997
## Staten Island:Shared room-Queens:Shared room               41.9696970
##                                                                   lwr
## Brooklyn:Entire home/apt-Bronx:Entire home/apt             28.0529766
## Manhattan:Entire home/apt-Bronx:Entire home/apt            64.2846694
## Queens:Entire home/apt-Bronx:Entire home/apt                8.6450747
## Staten Island:Entire home/apt-Bronx:Entire home/apt       -15.3748726
## Bronx:Private room-Bronx:Entire home/apt                  -71.1043797
## Brooklyn:Private room-Bronx:Entire home/apt               -55.9462162
## Manhattan:Private room-Bronx:Entire home/apt              -26.4714887
## Queens:Private room-Bronx:Entire home/apt                 -62.3766088
## Staten Island:Private room-Bronx:Entire home/apt          -75.5803067
## Bronx:Shared room-Bronx:Entire home/apt                  -106.5498777
## Brooklyn:Shared room-Bronx:Entire home/apt                -86.5032124
## Manhattan:Shared room-Bronx:Entire home/apt               -59.1396190
## Queens:Shared room-Bronx:Entire home/apt                  -91.7864994
## Staten Island:Shared room-Bronx:Entire home/apt          -142.3452835
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt         33.0177230
## Queens:Entire home/apt-Brooklyn:Entire home/apt           -24.0333176
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt    -51.5566665
## Bronx:Private room-Brooklyn:Entire home/apt              -105.4179714
## Brooklyn:Private room-Brooklyn:Entire home/apt            -87.2840163
## Manhattan:Private room-Brooklyn:Entire home/apt           -57.9683584
## Queens:Private room-Brooklyn:Entire home/apt              -94.5284434
## Staten Island:Private room-Brooklyn:Entire home/apt      -111.6610680
## Bronx:Shared room-Brooklyn:Entire home/apt               -144.3120142
## Brooklyn:Shared room-Brooklyn:Entire home/apt            -121.8854350
## Manhattan:Shared room-Brooklyn:Entire home/apt            -94.1714861
## Queens:Shared room-Brooklyn:Entire home/apt              -128.0955740
## Staten Island:Shared room-Brooklyn:Entire home/apt       -181.3628812
## Queens:Entire home/apt-Manhattan:Entire home/apt          -60.1795622
## Staten Island:Entire home/apt-Manhattan:Entire home/apt   -87.7419848
## Bronx:Private room-Manhattan:Entire home/apt             -141.5875370
## Brooklyn:Private room-Manhattan:Entire home/apt          -123.3919264
## Manhattan:Private room-Manhattan:Entire home/apt          -94.0826404
## Queens:Private room-Manhattan:Entire home/apt            -130.6629960
## Staten Island:Private room-Manhattan:Entire home/apt     -147.8456868
## Bronx:Shared room-Manhattan:Entire home/apt              -180.5070142
## Brooklyn:Shared room-Manhattan:Entire home/apt           -158.0648281
## Manhattan:Shared room-Manhattan:Entire home/apt          -130.3479463
## Queens:Shared room-Manhattan:Entire home/apt             -164.2817560
## Staten Island:Shared room-Manhattan:Entire home/apt      -217.5645843
## Staten Island:Entire home/apt-Queens:Entire home/apt      -33.4729354
## Bronx:Private room-Queens:Entire home/apt                 -87.7516689
## Brooklyn:Private room-Queens:Entire home/apt              -70.7602561
## Manhattan:Private room-Queens:Entire home/apt             -41.3592431
## Queens:Private room-Queens:Entire home/apt                -77.6030601
## Staten Island:Private room-Queens:Entire home/apt         -93.5967844
## Bronx:Shared room-Queens:Entire home/apt                 -125.9526959
## Brooklyn:Shared room-Queens:Entire home/apt              -103.9640067
## Manhattan:Shared room-Queens:Entire home/apt              -76.3281549
## Queens:Shared room-Queens:Entire home/apt                -109.9877263
## Staten Island:Shared room-Queens:Entire home/apt         -162.8080647
## Bronx:Private room-Staten Island:Entire home/apt          -79.5410105
## Brooklyn:Private room-Staten Island:Entire home/apt       -65.0810370
## Manhattan:Private room-Staten Island:Entire home/apt      -35.5867865
## Queens:Private room-Staten Island:Entire home/apt         -71.3941825
## Staten Island:Private room-Staten Island:Entire home/apt  -83.1161643
## Bronx:Shared room-Staten Island:Entire home/apt          -112.7466234
## Brooklyn:Shared room-Staten Island:Entire home/apt        -94.4518219
## Manhattan:Shared room-Staten Island:Entire home/apt       -67.2661595
## Queens:Shared room-Staten Island:Entire home/apt          -99.1696682
## Staten Island:Shared room-Staten Island:Entire home/apt  -147.2573497
## Brooklyn:Private room-Bronx:Private room                    3.4787582
## Manhattan:Private room-Bronx:Private room                  32.9348821
## Queens:Private room-Bronx:Private room                     -3.0607041
## Staten Island:Private room-Bronx:Private room             -17.2888493
## Bronx:Shared room-Bronx:Private room                      -48.9045563
## Brooklyn:Shared room-Bronx:Private room                   -27.9731966
## Manhattan:Shared room-Bronx:Private room                   -0.4981266
## Queens:Shared room-Bronx:Private room                     -33.5773280
## Staten Island:Shared room-Bronx:Private room              -85.2245777
## Manhattan:Private room-Brooklyn:Private room               26.0284023
## Queens:Private room-Brooklyn:Private room                 -10.5312716
## Staten Island:Private room-Brooklyn:Private room          -27.6628595
## Bronx:Shared room-Brooklyn:Private room                   -60.3135887
## Brooklyn:Shared room-Brooklyn:Private room                -37.8873357
## Manhattan:Shared room-Brooklyn:Private room               -10.1734479
## Queens:Shared room-Brooklyn:Private room                  -44.0973329
## Staten Island:Shared room-Brooklyn:Private room           -97.3643154
## Queens:Private room-Manhattan:Private room                -40.2393215
## Staten Island:Private room-Manhattan:Private room         -57.2525758
## Bronx:Shared room-Manhattan:Private room                  -89.8779579
## Brooklyn:Shared room-Manhattan:Private room               -67.4897514
## Manhattan:Shared room-Manhattan:Private room              -39.7829673
## Queens:Shared room-Manhattan:Private room                 -73.6832414
## Staten Island:Shared room-Manhattan:Private room         -126.9122682
## Staten Island:Private room-Queens:Private room            -21.9372924
## Bronx:Shared room-Queens:Private room                     -54.4329270
## Brooklyn:Shared room-Queens:Private room                  -32.2381893
## Manhattan:Shared room-Queens:Private room                  -4.5665645
## Queens:Shared room-Queens:Private room                    -38.3486604
## Staten Island:Shared room-Queens:Private room             -91.3820939
## Bronx:Shared room-Staten Island:Private room              -51.8164217
## Brooklyn:Shared room-Staten Island:Private room           -33.3146843
## Manhattan:Shared room-Staten Island:Private room           -6.1103590
## Queens:Shared room-Staten Island:Private room             -38.0949635
## Staten Island:Shared room-Staten Island:Private room      -86.4980324
## Brooklyn:Shared room-Bronx:Shared room                    -33.1502497
## Manhattan:Shared room-Bronx:Shared room                    -6.2970923
## Queens:Shared room-Bronx:Shared room                      -36.6368372
## Staten Island:Shared room-Bronx:Shared room               -74.7012577
## Manhattan:Shared room-Brooklyn:Shared room                  9.9954844
## Queens:Shared room-Brooklyn:Shared room                   -22.4916780
## Staten Island:Shared room-Brooklyn:Shared room            -72.5910568
## Queens:Shared room-Manhattan:Shared room                  -48.1533733
## Staten Island:Shared room-Manhattan:Shared room           -98.8664014
## Staten Island:Shared room-Queens:Shared room              -71.6008445
##                                                                   upr
## Brooklyn:Entire home/apt-Bronx:Entire home/apt             51.0619464
## Manhattan:Entire home/apt-Bronx:Entire home/apt            87.2392262
## Queens:Entire home/apt-Bronx:Entire home/apt               33.1969504
## Staten Island:Entire home/apt-Bronx:Entire home/apt        24.0151410
## Bronx:Private room-Bronx:Entire home/apt                  -42.6767804
## Brooklyn:Private room-Bronx:Entire home/apt               -32.9361088
## Manhattan:Private room-Bronx:Entire home/apt               -3.3285728
## Queens:Private room-Bronx:Entire home/apt                 -38.5547540
## Staten Island:Private room-Bronx:Entire home/apt          -37.1358351
## Bronx:Shared room-Bronx:Entire home/apt                   -37.0384253
## Brooklyn:Shared room-Bronx:Entire home/apt                -53.2104874
## Manhattan:Shared room-Bronx:Entire home/apt               -27.7507119
## Queens:Shared room-Bronx:Entire home/apt                  -51.1126261
## Staten Island:Shared room-Bronx:Entire home/apt            83.3855520
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt         39.3912497
## Queens:Entire home/apt-Brooklyn:Entire home/apt           -13.2395803
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt    -18.9179880
## Bronx:Private room-Brooklyn:Entire home/apt               -87.4781117
## Brooklyn:Private room-Brooklyn:Entire home/apt            -80.7132318
## Manhattan:Private room-Brooklyn:Entire home/apt           -50.9466261
## Queens:Private room-Brooklyn:Entire home/apt              -85.5178423
## Staten Island:Private room-Brooklyn:Entire home/apt       -80.1699968
## Bronx:Shared room-Brooklyn:Entire home/apt                -78.3912118
## Brooklyn:Shared room-Brooklyn:Entire home/apt             -96.9431877
## Manhattan:Shared room-Brooklyn:Entire home/apt            -71.8337678
## Queens:Shared room-Brooklyn:Entire home/apt               -93.9184745
## Staten Island:Shared room-Brooklyn:Entire home/apt         43.2882267
## Queens:Entire home/apt-Manhattan:Entire home/apt          -49.5023084
## Staten Island:Entire home/apt-Manhattan:Entire home/apt   -55.1416424
## Bronx:Private room-Manhattan:Entire home/apt             -123.7175188
## Brooklyn:Private room-Manhattan:Entire home/apt          -117.0142943
## Manhattan:Private room-Manhattan:Entire home/apt          -87.2413168
## Queens:Private room-Manhattan:Entire home/apt            -121.7922624
## Staten Island:Private room-Manhattan:Entire home/apt     -116.3943507
## Bronx:Shared room-Manhattan:Entire home/apt              -114.6051844
## Brooklyn:Shared room-Manhattan:Entire home/apt           -133.1727674
## Manhattan:Shared room-Manhattan:Entire home/apt          -108.0662803
## Queens:Shared room-Manhattan:Entire home/apt             -130.1412652
## Staten Island:Shared room-Manhattan:Entire home/apt         7.0809571
## Staten Island:Entire home/apt-Queens:Entire home/apt        0.2711788
## Bronx:Private room-Queens:Entire home/apt                 -67.8715162
## Brooklyn:Private room-Queens:Entire home/apt              -59.9640941
## Manhattan:Private room-Queens:Entire home/apt             -30.2828434
## Queens:Private room-Queens:Entire home/apt                -65.1703276
## Staten Island:Private room-Queens:Entire home/apt         -60.9613824
## Bronx:Shared room-Queens:Entire home/apt                  -59.4776322
## Brooklyn:Shared room-Queens:Entire home/apt               -77.5917181
## Manhattan:Shared room-Queens:Entire home/apt              -52.4042011
## Queens:Shared room-Queens:Entire home/apt                 -74.7534243
## Staten Island:Shared room-Queens:Entire home/apt           62.0063081
## Bronx:Private room-Staten Island:Entire home/apt          -42.8804180
## Brooklyn:Private room-Staten Island:Entire home/apt       -32.4415565
## Manhattan:Private room-Staten Island:Entire home/apt       -2.8535434
## Queens:Private room-Staten Island:Entire home/apt         -38.1774487
## Staten Island:Private room-Staten Island:Entire home/apt  -38.2402460
## Bronx:Shared room-Staten Island:Entire home/apt           -39.4819480
## Brooklyn:Shared room-Staten Island:Entire home/apt        -53.9021464
## Manhattan:Shared room-Staten Island:Entire home/apt       -28.2644399
## Queens:Shared room-Staten Island:Entire home/apt          -52.3697258
## Staten Island:Shared room-Staten Island:Entire home/apt    79.6573497
## Brooklyn:Private room-Bronx:Private room                   21.4200768
## Manhattan:Private room-Bronx:Private room                  51.0462165
## Queens:Private room-Bronx:Private room                     15.9105014
## Staten Island:Private room-Bronx:Private room              18.3538676
## Bronx:Shared room-Bronx:Private room                       19.0974135
## Brooklyn:Shared room-Bronx:Private room                     2.0406570
## Manhattan:Shared room-Bronx:Private room                   27.3889558
## Queens:Shared room-Bronx:Private room                       4.4593627
## Staten Island:Shared room-Bronx:Private room              140.0460063
## Manhattan:Private room-Brooklyn:Private room               33.0538613
## Queens:Private room-Brooklyn:Private room                  -1.5177661
## Staten Island:Private room-Brooklyn:Private room            3.8290428
## Bronx:Shared room-Brooklyn:Private room                     5.6076108
## Brooklyn:Shared room-Brooklyn:Private room                -12.9440390
## Manhattan:Shared room-Brooklyn:Private room                12.1654421
## Queens:Shared room-Brooklyn:Private room                   -9.9194675
## Staten Island:Shared room-Brooklyn:Private room           127.2869090
## Queens:Private room-Manhattan:Private room                -30.8919797
## Staten Island:Private room-Manhattan:Private room         -25.6635045
## Bronx:Shared room-Manhattan:Private room                  -23.9102836
## Brooklyn:Shared room-Manhattan:Private room               -42.4238868
## Manhattan:Shared room-Manhattan:Private room              -17.3073021
## Queens:Shared room-Manhattan:Private room                 -39.4158225
## Staten Island:Shared room-Manhattan:Private room           97.7525981
## Staten Island:Private room-Queens:Private room             10.1525134
## Bronx:Shared room-Queens:Private room                      11.7759868
## Brooklyn:Shared room-Queens:Private room                   -6.5441477
## Manhattan:Shared room-Queens:Private room                  18.6075963
## Queens:Shared room-Queens:Private room                     -3.6191023
## Staten Island:Shared room-Queens:Private room             133.3537251
## Bronx:Shared room-Staten Island:Private room               20.9442606
## Brooklyn:Shared room-Staten Island:Private room             6.3171263
## Manhattan:Shared room-Staten Island:Private room           31.9361699
## Queens:Shared room-Staten Island:Private room               7.9119798
## Staten Island:Shared room-Staten Island:Private room      140.2544427
## Brooklyn:Shared room-Bronx:Shared room                     37.0248529
## Manhattan:Shared room-Bronx:Shared room                    62.9950644
## Queens:Shared room-Bronx:Shared room                       37.3260147
## Staten Island:Shared room-Bronx:Shared room               159.3298291
## Manhattan:Shared room-Brooklyn:Shared room                 42.8278845
## Queens:Shared room-Brooklyn:Shared room                    19.3062523
## Staten Island:Shared room-Brooklyn:Shared room            153.3450251
## Queens:Shared room-Manhattan:Shared room                   -7.8554213
## Staten Island:Shared room-Manhattan:Shared room           126.7970008
## Staten Island:Shared room-Queens:Shared room              155.5402384
##                                                              p adj
## Brooklyn:Entire home/apt-Bronx:Entire home/apt           0.0000000
## Manhattan:Entire home/apt-Bronx:Entire home/apt          0.0000000
## Queens:Entire home/apt-Bronx:Entire home/apt             0.0000008
## Staten Island:Entire home/apt-Bronx:Entire home/apt      0.9999901
## Bronx:Private room-Bronx:Entire home/apt                 0.0000000
## Brooklyn:Private room-Bronx:Entire home/apt              0.0000000
## Manhattan:Private room-Bronx:Entire home/apt             0.0012031
## Queens:Private room-Bronx:Entire home/apt                0.0000000
## Staten Island:Private room-Bronx:Entire home/apt         0.0000000
## Bronx:Shared room-Bronx:Entire home/apt                  0.0000000
## Brooklyn:Shared room-Bronx:Entire home/apt               0.0000000
## Manhattan:Shared room-Bronx:Entire home/apt              0.0000000
## Queens:Shared room-Bronx:Entire home/apt                 0.0000000
## Staten Island:Shared room-Bronx:Entire home/apt          0.9999147
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt       0.0000000
## Queens:Entire home/apt-Brooklyn:Entire home/apt          0.0000000
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt   0.0000000
## Bronx:Private room-Brooklyn:Entire home/apt              0.0000000
## Brooklyn:Private room-Brooklyn:Entire home/apt           0.0000000
## Manhattan:Private room-Brooklyn:Entire home/apt          0.0000000
## Queens:Private room-Brooklyn:Entire home/apt             0.0000000
## Staten Island:Private room-Brooklyn:Entire home/apt      0.0000000
## Bronx:Shared room-Brooklyn:Entire home/apt               0.0000000
## Brooklyn:Shared room-Brooklyn:Entire home/apt            0.0000000
## Manhattan:Shared room-Brooklyn:Entire home/apt           0.0000000
## Queens:Shared room-Brooklyn:Entire home/apt              0.0000000
## Staten Island:Shared room-Brooklyn:Entire home/apt       0.7457561
## Queens:Entire home/apt-Manhattan:Entire home/apt         0.0000000
## Staten Island:Entire home/apt-Manhattan:Entire home/apt  0.0000000
## Bronx:Private room-Manhattan:Entire home/apt             0.0000000
## Brooklyn:Private room-Manhattan:Entire home/apt          0.0000000
## Manhattan:Private room-Manhattan:Entire home/apt         0.0000000
## Queens:Private room-Manhattan:Entire home/apt            0.0000000
## Staten Island:Private room-Manhattan:Entire home/apt     0.0000000
## Bronx:Shared room-Manhattan:Entire home/apt              0.0000000
## Brooklyn:Shared room-Manhattan:Entire home/apt           0.0000000
## Manhattan:Shared room-Manhattan:Entire home/apt          0.0000000
## Queens:Shared room-Manhattan:Entire home/apt             0.0000000
## Staten Island:Shared room-Manhattan:Entire home/apt      0.0949816
## Staten Island:Entire home/apt-Queens:Entire home/apt     0.0592759
## Bronx:Private room-Queens:Entire home/apt                0.0000000
## Brooklyn:Private room-Queens:Entire home/apt             0.0000000
## Manhattan:Private room-Queens:Entire home/apt            0.0000000
## Queens:Private room-Queens:Entire home/apt               0.0000000
## Staten Island:Private room-Queens:Entire home/apt        0.0000000
## Bronx:Shared room-Queens:Entire home/apt                 0.0000000
## Brooklyn:Shared room-Queens:Entire home/apt              0.0000000
## Manhattan:Shared room-Queens:Entire home/apt             0.0000000
## Queens:Shared room-Queens:Entire home/apt                0.0000000
## Staten Island:Shared room-Queens:Entire home/apt         0.9734952
## Bronx:Private room-Staten Island:Entire home/apt         0.0000000
## Brooklyn:Private room-Staten Island:Entire home/apt      0.0000000
## Manhattan:Private room-Staten Island:Entire home/apt     0.0060403
## Queens:Private room-Staten Island:Entire home/apt        0.0000000
## Staten Island:Private room-Staten Island:Entire home/apt 0.0000000
## Bronx:Shared room-Staten Island:Entire home/apt          0.0000000
## Brooklyn:Shared room-Staten Island:Entire home/apt       0.0000000
## Manhattan:Shared room-Staten Island:Entire home/apt      0.0000000
## Queens:Shared room-Staten Island:Entire home/apt         0.0000000
## Staten Island:Shared room-Staten Island:Entire home/apt  0.9995992
## Brooklyn:Private room-Bronx:Private room                 0.0002505
## Manhattan:Private room-Bronx:Private room                0.0000000
## Queens:Private room-Bronx:Private room                   0.5927958
## Staten Island:Private room-Bronx:Private room            1.0000000
## Bronx:Shared room-Bronx:Private room                     0.9783119
## Brooklyn:Shared room-Bronx:Private room                  0.1823186
## Manhattan:Shared room-Bronx:Private room                 0.0725456
## Queens:Shared room-Bronx:Private room                    0.3722557
## Staten Island:Shared room-Bronx:Private room             0.9999639
## Manhattan:Private room-Brooklyn:Private room             0.0000000
## Queens:Private room-Brooklyn:Private room                0.0005663
## Staten Island:Private room-Brooklyn:Private room         0.3926501
## Bronx:Shared room-Brooklyn:Private room                  0.2388147
## Brooklyn:Shared room-Brooklyn:Private room               0.0000000
## Manhattan:Shared room-Brooklyn:Private room              1.0000000
## Queens:Shared room-Brooklyn:Private room                 0.0000086
## Staten Island:Shared room-Brooklyn:Private room          1.0000000
## Queens:Private room-Manhattan:Private room               0.0000000
## Staten Island:Private room-Manhattan:Private room        0.0000000
## Bronx:Shared room-Manhattan:Private room                 0.0000005
## Brooklyn:Shared room-Manhattan:Private room              0.0000000
## Manhattan:Shared room-Manhattan:Private room             0.0000000
## Queens:Shared room-Manhattan:Private room                0.0000000
## Staten Island:Shared room-Manhattan:Private room         1.0000000
## Staten Island:Private room-Queens:Private room           0.9960658
## Bronx:Shared room-Queens:Private room                    0.6759396
## Brooklyn:Shared room-Queens:Private room                 0.0000314
## Manhattan:Shared room-Queens:Private room                0.7650326
## Queens:Shared room-Queens:Private room                   0.0037890
## Staten Island:Shared room-Queens:Private room            0.9999987
## Bronx:Shared room-Staten Island:Private room             0.9838607
## Brooklyn:Shared room-Staten Island:Private room          0.5828455
## Manhattan:Shared room-Staten Island:Private room         0.5890421
## Queens:Shared room-Staten Island:Private room            0.6467812
## Staten Island:Shared room-Staten Island:Private room     0.9999738
## Brooklyn:Shared room-Bronx:Shared room                   1.0000000
## Manhattan:Shared room-Bronx:Shared room                  0.2603998
## Queens:Shared room-Bronx:Shared room                     1.0000000
## Staten Island:Shared room-Bronx:Shared room              0.9966469
## Manhattan:Shared room-Brooklyn:Shared room               0.0000050
## Queens:Shared room-Brooklyn:Shared room                  1.0000000
## Staten Island:Shared room-Brooklyn:Shared room           0.9970310
## Queens:Shared room-Manhattan:Shared room                 0.0002421
## Staten Island:Shared room-Manhattan:Shared room          1.0000000
## Staten Island:Shared room-Queens:Shared room             0.9958048
plot(TukeyHSD(nyc.model.fit,"neighbourhood_group:room_type", conf.level = .95))

nyc.anova.diff2 = tidy(nyc.anova.diff)
colnames(nyc.anova.diff2)[3] <- "diff"
invisible(view(nyc.anova.diff2))

nyc.anova.diffdf <- nyc.anova.diff2[nyc.anova.diff2$adj.p.value <0.05,]
nyc.anova.diffdf <- nyc.anova.diffdf[order(nyc.anova.diffdf$diff),]
nyc.anova.diffdf
## # A tibble: 69 x 6
##    term         comparison              diff conf.low conf.high adj.p.value
##    <chr>        <chr>                  <dbl>    <dbl>     <dbl>       <dbl>
##  1 neighbourho… Bronx:Shared room-Man… -148.    -181.    -115.            0
##  2 neighbourho… Queens:Shared room-Ma… -147.    -164.    -130.            0
##  3 neighbourho… Brooklyn:Shared room-… -146.    -158.    -133.            0
##  4 neighbourho… Bronx:Private room-Ma… -133.    -142.    -124.            0
##  5 neighbourho… Staten Island:Private… -132.    -148.    -116.            0
##  6 neighbourho… Queens:Private room-M… -126.    -131.    -122.            0
##  7 neighbourho… Brooklyn:Private room… -120.    -123.    -117.            0
##  8 neighbourho… Manhattan:Shared room… -119.    -130.    -108.            0
##  9 neighbourho… Bronx:Shared room-Bro… -111.    -144.     -78.4           0
## 10 neighbourho… Queens:Shared room-Br… -111.    -128.     -93.9           0
## # … with 59 more rows

Multiple Test Technique on Log Transformationl: Tukey-Kramer

  • From the F-test table we can see that all current variables are statistically significnat at the 0.05 alpha level
  • Move forward with the Tukey-Kramer to discover what factors and/or combinations contribute to predicting the price of a NYC AirBnB
nyc.anova.log.diff <- TukeyHSD(nyc.model.fit.log,"neighbourhood_group:room_type", conf.level = .95)
nyc.anova.log.diff
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = lprice ~ neighbourhood_group + room_type + neighbourhood_group:room_type, data = nyc.log.anova)
## 
## $`neighbourhood_group:room_type`
##                                                                  diff
## Brooklyn:Entire home/apt-Bronx:Entire home/apt            0.307834203
## Manhattan:Entire home/apt-Bronx:Entire home/apt           0.531175865
## Queens:Entire home/apt-Bronx:Entire home/apt              0.164533624
## Staten Island:Entire home/apt-Bronx:Entire home/apt       0.035428408
## Bronx:Private room-Bronx:Entire home/apt                 -0.663577130
## Brooklyn:Private room-Bronx:Entire home/apt              -0.472728923
## Manhattan:Private room-Bronx:Entire home/apt             -0.142588033
## Queens:Private room-Bronx:Entire home/apt                -0.556406256
## Staten Island:Private room-Bronx:Entire home/apt         -0.666839002
## Bronx:Shared room-Bronx:Entire home/apt                  -0.988941956
## Brooklyn:Shared room-Bronx:Entire home/apt               -0.960062946
## Manhattan:Shared room-Bronx:Entire home/apt              -0.484704547
## Queens:Shared room-Bronx:Entire home/apt                 -0.955586120
## Staten Island:Shared room-Bronx:Entire home/apt          -0.398743547
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt        0.223341662
## Queens:Entire home/apt-Brooklyn:Entire home/apt          -0.143300579
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt   -0.272405795
## Bronx:Private room-Brooklyn:Entire home/apt              -0.971411333
## Brooklyn:Private room-Brooklyn:Entire home/apt           -0.780563126
## Manhattan:Private room-Brooklyn:Entire home/apt          -0.450422236
## Queens:Private room-Brooklyn:Entire home/apt             -0.864240459
## Staten Island:Private room-Brooklyn:Entire home/apt      -0.974673205
## Bronx:Shared room-Brooklyn:Entire home/apt               -1.296776159
## Brooklyn:Shared room-Brooklyn:Entire home/apt            -1.267897149
## Manhattan:Shared room-Brooklyn:Entire home/apt           -0.792538749
## Queens:Shared room-Brooklyn:Entire home/apt              -1.263420322
## Staten Island:Shared room-Brooklyn:Entire home/apt       -0.706577750
## Queens:Entire home/apt-Manhattan:Entire home/apt         -0.366642241
## Staten Island:Entire home/apt-Manhattan:Entire home/apt  -0.495747457
## Bronx:Private room-Manhattan:Entire home/apt             -1.194752995
## Brooklyn:Private room-Manhattan:Entire home/apt          -1.003904788
## Manhattan:Private room-Manhattan:Entire home/apt         -0.673763898
## Queens:Private room-Manhattan:Entire home/apt            -1.087582121
## Staten Island:Private room-Manhattan:Entire home/apt     -1.198014866
## Bronx:Shared room-Manhattan:Entire home/apt              -1.520117820
## Brooklyn:Shared room-Manhattan:Entire home/apt           -1.491238811
## Manhattan:Shared room-Manhattan:Entire home/apt          -1.015880411
## Queens:Shared room-Manhattan:Entire home/apt             -1.486761984
## Staten Island:Shared room-Manhattan:Entire home/apt      -0.929919412
## Staten Island:Entire home/apt-Queens:Entire home/apt     -0.129105216
## Bronx:Private room-Queens:Entire home/apt                -0.828110754
## Brooklyn:Private room-Queens:Entire home/apt             -0.637262547
## Manhattan:Private room-Queens:Entire home/apt            -0.307121657
## Queens:Private room-Queens:Entire home/apt               -0.720939880
## Staten Island:Private room-Queens:Entire home/apt        -0.831372625
## Bronx:Shared room-Queens:Entire home/apt                 -1.153475579
## Brooklyn:Shared room-Queens:Entire home/apt              -1.124596570
## Manhattan:Shared room-Queens:Entire home/apt             -0.649238170
## Queens:Shared room-Queens:Entire home/apt                -1.120119743
## Staten Island:Shared room-Queens:Entire home/apt         -0.563277171
## Bronx:Private room-Staten Island:Entire home/apt         -0.699005538
## Brooklyn:Private room-Staten Island:Entire home/apt      -0.508157331
## Manhattan:Private room-Staten Island:Entire home/apt     -0.178016441
## Queens:Private room-Staten Island:Entire home/apt        -0.591834664
## Staten Island:Private room-Staten Island:Entire home/apt -0.702267410
## Bronx:Shared room-Staten Island:Entire home/apt          -1.024370364
## Brooklyn:Shared room-Staten Island:Entire home/apt       -0.995491354
## Manhattan:Shared room-Staten Island:Entire home/apt      -0.520132955
## Queens:Shared room-Staten Island:Entire home/apt         -0.991014527
## Staten Island:Shared room-Staten Island:Entire home/apt  -0.434171955
## Brooklyn:Private room-Bronx:Private room                  0.190848207
## Manhattan:Private room-Bronx:Private room                 0.520989097
## Queens:Private room-Bronx:Private room                    0.107170874
## Staten Island:Private room-Bronx:Private room            -0.003261872
## Bronx:Shared room-Bronx:Private room                     -0.325364825
## Brooklyn:Shared room-Bronx:Private room                  -0.296485816
## Manhattan:Shared room-Bronx:Private room                  0.178872584
## Queens:Shared room-Bronx:Private room                    -0.292008989
## Staten Island:Shared room-Bronx:Private room              0.264833583
## Manhattan:Private room-Brooklyn:Private room              0.330140890
## Queens:Private room-Brooklyn:Private room                -0.083677333
## Staten Island:Private room-Brooklyn:Private room         -0.194110079
## Bronx:Shared room-Brooklyn:Private room                  -0.516213032
## Brooklyn:Shared room-Brooklyn:Private room               -0.487334023
## Manhattan:Shared room-Brooklyn:Private room              -0.011975623
## Queens:Shared room-Brooklyn:Private room                 -0.482857196
## Staten Island:Shared room-Brooklyn:Private room           0.073985376
## Queens:Private room-Manhattan:Private room               -0.413818223
## Staten Island:Private room-Manhattan:Private room        -0.524250969
## Bronx:Shared room-Manhattan:Private room                 -0.846353923
## Brooklyn:Shared room-Manhattan:Private room              -0.817474913
## Manhattan:Shared room-Manhattan:Private room             -0.342116514
## Queens:Shared room-Manhattan:Private room                -0.812998087
## Staten Island:Shared room-Manhattan:Private room         -0.256155514
## Staten Island:Private room-Queens:Private room           -0.110432746
## Bronx:Shared room-Queens:Private room                    -0.432535700
## Brooklyn:Shared room-Queens:Private room                 -0.403656690
## Manhattan:Shared room-Queens:Private room                 0.071701710
## Queens:Shared room-Queens:Private room                   -0.399179863
## Staten Island:Shared room-Queens:Private room             0.157662709
## Bronx:Shared room-Staten Island:Private room             -0.322102954
## Brooklyn:Shared room-Staten Island:Private room          -0.293223945
## Manhattan:Shared room-Staten Island:Private room          0.182134455
## Queens:Shared room-Staten Island:Private room            -0.288747118
## Staten Island:Shared room-Staten Island:Private room      0.268095455
## Brooklyn:Shared room-Bronx:Shared room                    0.028879009
## Manhattan:Shared room-Bronx:Shared room                   0.504237409
## Queens:Shared room-Bronx:Shared room                      0.033355836
## Staten Island:Shared room-Bronx:Shared room               0.590198408
## Manhattan:Shared room-Brooklyn:Shared room                0.475358400
## Queens:Shared room-Brooklyn:Shared room                   0.004476827
## Staten Island:Shared room-Brooklyn:Shared room            0.561319399
## Queens:Shared room-Manhattan:Shared room                 -0.470881573
## Staten Island:Shared room-Manhattan:Shared room           0.085960999
## Staten Island:Shared room-Queens:Shared room              0.556842572
##                                                                   lwr
## Brooklyn:Entire home/apt-Bronx:Entire home/apt            0.226785077
## Manhattan:Entire home/apt-Bronx:Entire home/apt           0.450318409
## Queens:Entire home/apt-Bronx:Entire home/apt              0.078049611
## Staten Island:Entire home/apt-Bronx:Entire home/apt      -0.103322965
## Bronx:Private room-Bronx:Entire home/apt                 -0.763713385
## Brooklyn:Private room-Bronx:Entire home/apt              -0.553782056
## Manhattan:Private room-Bronx:Entire home/apt             -0.224108984
## Queens:Private room-Bronx:Entire home/apt                -0.640318770
## Staten Island:Private room-Bronx:Entire home/apt         -0.802259702
## Bronx:Shared room-Bronx:Entire home/apt                  -1.233796135
## Brooklyn:Shared room-Bronx:Entire home/apt               -1.077336612
## Manhattan:Shared room-Bronx:Entire home/apt              -0.595272012
## Queens:Shared room-Bronx:Entire home/apt                 -1.098859890
## Staten Island:Shared room-Bronx:Entire home/apt          -1.193880701
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt        0.200890906
## Queens:Entire home/apt-Brooklyn:Entire home/apt          -0.181321532
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt   -0.387375581
## Bronx:Private room-Brooklyn:Entire home/apt              -1.034604512
## Brooklyn:Private room-Brooklyn:Entire home/apt           -0.803708723
## Manhattan:Private room-Brooklyn:Entire home/apt          -0.475156297
## Queens:Private room-Brooklyn:Entire home/apt             -0.895980313
## Staten Island:Private room-Brooklyn:Entire home/apt      -1.085600543
## Bronx:Shared room-Brooklyn:Entire home/apt               -1.528982268
## Brooklyn:Shared room-Brooklyn:Entire home/apt            -1.355756247
## Manhattan:Shared room-Brooklyn:Entire home/apt           -0.871223390
## Queens:Shared room-Brooklyn:Entire home/apt              -1.383809199
## Staten Island:Shared room-Brooklyn:Entire home/apt       -1.497911562
## Queens:Entire home/apt-Manhattan:Entire home/apt         -0.404252881
## Staten Island:Entire home/apt-Manhattan:Entire home/apt  -0.610582204
## Bronx:Private room-Manhattan:Entire home/apt             -1.257700157
## Brooklyn:Private room-Manhattan:Entire home/apt          -1.026370005
## Manhattan:Private room-Manhattan:Entire home/apt         -0.697862469
## Queens:Private room-Manhattan:Entire home/apt            -1.118829291
## Staten Island:Private room-Manhattan:Entire home/apt     -1.308802238
## Bronx:Shared room-Manhattan:Entire home/apt              -1.752257099
## Brooklyn:Shared room-Manhattan:Entire home/apt           -1.578921126
## Manhattan:Shared room-Manhattan:Entire home/apt          -1.094367608
## Queens:Shared room-Manhattan:Entire home/apt             -1.607021906
## Staten Island:Shared room-Manhattan:Entire home/apt      -1.721233615
## Staten Island:Entire home/apt-Queens:Entire home/apt     -0.247968901
## Bronx:Private room-Queens:Entire home/apt                -0.898138617
## Brooklyn:Private room-Queens:Entire home/apt             -0.675292041
## Manhattan:Private room-Queens:Entire home/apt            -0.346138289
## Queens:Private room-Queens:Entire home/apt               -0.764734196
## Staten Island:Private room-Queens:Entire home/apt        -0.946330870
## Bronx:Shared room-Queens:Entire home/apt                 -1.387634075
## Brooklyn:Shared room-Queens:Entire home/apt              -1.217492990
## Manhattan:Shared room-Queens:Entire home/apt             -0.733510328
## Queens:Shared room-Queens:Entire home/apt                -1.244232617
## Staten Island:Shared room-Queens:Entire home/apt         -1.355186083
## Bronx:Private room-Staten Island:Entire home/apt         -0.828142522
## Brooklyn:Private room-Staten Island:Entire home/apt      -0.623129942
## Manhattan:Private room-Staten Island:Entire home/apt     -0.293319331
## Queens:Private room-Staten Island:Entire home/apt        -0.708840651
## Staten Island:Private room-Staten Island:Entire home/apt -0.860342889
## Bronx:Shared room-Staten Island:Entire home/apt          -1.282445275
## Brooklyn:Shared room-Staten Island:Entire home/apt       -1.138327637
## Manhattan:Shared room-Staten Island:Entire home/apt      -0.657516561
## Queens:Shared room-Staten Island:Entire home/apt         -1.155867384
## Staten Island:Shared room-Staten Island:Entire home/apt  -1.233479270
## Brooklyn:Private room-Bronx:Private room                  0.127649889
## Manhattan:Private room-Bronx:Private room                 0.457191899
## Queens:Private room-Bronx:Private room                    0.040344779
## Staten Island:Private room-Bronx:Private room            -0.128813387
## Bronx:Shared room-Bronx:Private room                     -0.564901850
## Brooklyn:Shared room-Bronx:Private room                  -0.402209653
## Manhattan:Shared room-Bronx:Private room                  0.080640301
## Queens:Shared room-Bronx:Private room                    -0.425993280
## Staten Island:Shared room-Bronx:Private room             -0.528682334
## Manhattan:Private room-Brooklyn:Private room              0.305393702
## Queens:Private room-Brooklyn:Private room                -0.115427417
## Staten Island:Private room-Brooklyn:Private room         -0.305040344
## Bronx:Shared room-Brooklyn:Private room                  -0.748420541
## Brooklyn:Shared room-Brooklyn:Private room               -0.575196817
## Manhattan:Shared room-Brooklyn:Private room              -0.090664392
## Queens:Shared room-Brooklyn:Private room                 -0.603248770
## Staten Island:Shared room-Brooklyn:Private room          -0.717348846
## Queens:Private room-Manhattan:Private room               -0.446744246
## Staten Island:Private room-Manhattan:Private room        -0.635523513
## Bronx:Shared room-Manhattan:Private room                 -1.078725139
## Brooklyn:Shared room-Manhattan:Private room              -0.905769453
## Manhattan:Shared room-Manhattan:Private room             -0.421287073
## Queens:Shared room-Manhattan:Private room                -0.933705113
## Staten Island:Shared room-Manhattan:Private room         -1.047537790
## Staten Island:Private room-Queens:Private room           -0.223469127
## Bronx:Shared room-Queens:Private room                    -0.665756682
## Brooklyn:Shared room-Queens:Private room                 -0.494163984
## Manhattan:Shared room-Queens:Private room                -0.009929301
## Queens:Shared room-Queens:Private room                   -0.521514776
## Staten Island:Shared room-Queens:Private room            -0.633969498
## Bronx:Shared room-Staten Island:Private room             -0.578402549
## Brooklyn:Shared room-Staten Island:Private room          -0.432827047
## Manhattan:Shared room-Staten Island:Private room          0.048115509
## Queens:Shared room-Staten Island:Private room            -0.450806634
## Staten Island:Shared room-Staten Island:Private room     -0.530640426
## Brooklyn:Shared room-Bronx:Shared room                   -0.218312878
## Manhattan:Shared room-Bronx:Shared room                   0.260155699
## Queens:Shared room-Bronx:Shared room                     -0.227178403
## Staten Island:Shared room-Bronx:Shared room              -0.234176391
## Manhattan:Shared room-Brooklyn:Shared room                0.359706229
## Queens:Shared room-Brooklyn:Shared room                  -0.142756435
## Staten Island:Shared room-Brooklyn:Shared room           -0.234540735
## Queens:Shared room-Manhattan:Shared room                 -0.612831160
## Staten Island:Shared room-Manhattan:Shared room          -0.708938620
## Staten Island:Shared room-Queens:Shared room             -0.243262179
##                                                                   upr
## Brooklyn:Entire home/apt-Bronx:Entire home/apt            0.388883328
## Manhattan:Entire home/apt-Bronx:Entire home/apt           0.612033320
## Queens:Entire home/apt-Bronx:Entire home/apt              0.251017637
## Staten Island:Entire home/apt-Bronx:Entire home/apt       0.174179781
## Bronx:Private room-Bronx:Entire home/apt                 -0.563440876
## Brooklyn:Private room-Bronx:Entire home/apt              -0.391675791
## Manhattan:Private room-Bronx:Entire home/apt             -0.061067082
## Queens:Private room-Bronx:Entire home/apt                -0.472493743
## Staten Island:Private room-Bronx:Entire home/apt         -0.531418302
## Bronx:Shared room-Bronx:Entire home/apt                  -0.744087777
## Brooklyn:Shared room-Bronx:Entire home/apt               -0.842789281
## Manhattan:Shared room-Bronx:Entire home/apt              -0.374137082
## Queens:Shared room-Bronx:Entire home/apt                 -0.812312350
## Staten Island:Shared room-Bronx:Entire home/apt           0.396393606
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt        0.245792418
## Queens:Entire home/apt-Brooklyn:Entire home/apt          -0.105279626
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt   -0.157436008
## Bronx:Private room-Brooklyn:Entire home/apt              -0.908218155
## Brooklyn:Private room-Brooklyn:Entire home/apt           -0.757417530
## Manhattan:Private room-Brooklyn:Entire home/apt          -0.425688175
## Queens:Private room-Brooklyn:Entire home/apt             -0.832500605
## Staten Island:Private room-Brooklyn:Entire home/apt      -0.863745867
## Bronx:Shared room-Brooklyn:Entire home/apt               -1.064570049
## Brooklyn:Shared room-Brooklyn:Entire home/apt            -1.180038051
## Manhattan:Shared room-Brooklyn:Entire home/apt           -0.713854108
## Queens:Shared room-Brooklyn:Entire home/apt              -1.143031446
## Staten Island:Shared room-Brooklyn:Entire home/apt        0.084756062
## Queens:Entire home/apt-Manhattan:Entire home/apt         -0.329031601
## Staten Island:Entire home/apt-Manhattan:Entire home/apt  -0.380912710
## Bronx:Private room-Manhattan:Entire home/apt             -1.131805833
## Brooklyn:Private room-Manhattan:Entire home/apt          -0.981439571
## Manhattan:Private room-Manhattan:Entire home/apt         -0.649665327
## Queens:Private room-Manhattan:Entire home/apt            -1.056334951
## Staten Island:Private room-Manhattan:Entire home/apt     -1.087227495
## Bronx:Shared room-Manhattan:Entire home/apt              -1.287978542
## Brooklyn:Shared room-Manhattan:Entire home/apt           -1.403556496
## Manhattan:Shared room-Manhattan:Entire home/apt          -0.937393214
## Queens:Shared room-Manhattan:Entire home/apt             -1.366502062
## Staten Island:Shared room-Manhattan:Entire home/apt      -0.138605208
## Staten Island:Entire home/apt-Queens:Entire home/apt     -0.010241531
## Bronx:Private room-Queens:Entire home/apt                -0.758082891
## Brooklyn:Private room-Queens:Entire home/apt             -0.599233053
## Manhattan:Private room-Queens:Entire home/apt            -0.268105025
## Queens:Private room-Queens:Entire home/apt               -0.677145564
## Staten Island:Private room-Queens:Entire home/apt        -0.716414380
## Bronx:Shared room-Queens:Entire home/apt                 -0.919317083
## Brooklyn:Shared room-Queens:Entire home/apt              -1.031700150
## Manhattan:Shared room-Queens:Entire home/apt             -0.564966013
## Queens:Shared room-Queens:Entire home/apt                -0.996006870
## Staten Island:Shared room-Queens:Entire home/apt          0.228631741
## Bronx:Private room-Staten Island:Entire home/apt         -0.569868555
## Brooklyn:Private room-Staten Island:Entire home/apt      -0.393184720
## Manhattan:Private room-Staten Island:Entire home/apt     -0.062713551
## Queens:Private room-Staten Island:Entire home/apt        -0.474828677
## Staten Island:Private room-Staten Island:Entire home/apt -0.544191931
## Bronx:Shared room-Staten Island:Entire home/apt          -0.766295452
## Brooklyn:Shared room-Staten Island:Entire home/apt       -0.852655071
## Manhattan:Shared room-Staten Island:Entire home/apt      -0.382749348
## Queens:Shared room-Staten Island:Entire home/apt         -0.826161671
## Staten Island:Shared room-Staten Island:Entire home/apt   0.365135360
## Brooklyn:Private room-Bronx:Private room                  0.254046525
## Manhattan:Private room-Bronx:Private room                 0.584786295
## Queens:Private room-Bronx:Private room                    0.173996969
## Staten Island:Private room-Bronx:Private room             0.122289644
## Bronx:Shared room-Bronx:Private room                     -0.085827801
## Brooklyn:Shared room-Bronx:Private room                  -0.190761979
## Manhattan:Shared room-Bronx:Private room                  0.277104867
## Queens:Shared room-Bronx:Private room                    -0.158024698
## Staten Island:Shared room-Bronx:Private room              1.058349500
## Manhattan:Private room-Brooklyn:Private room              0.354888078
## Queens:Private room-Brooklyn:Private room                -0.051927249
## Staten Island:Private room-Brooklyn:Private room         -0.083179813
## Bronx:Shared room-Brooklyn:Private room                  -0.284005524
## Brooklyn:Shared room-Brooklyn:Private room               -0.399471229
## Manhattan:Shared room-Brooklyn:Private room               0.066713145
## Queens:Shared room-Brooklyn:Private room                 -0.362465622
## Staten Island:Shared room-Brooklyn:Private room           0.865319598
## Queens:Private room-Manhattan:Private room               -0.380892200
## Staten Island:Private room-Manhattan:Private room        -0.412978425
## Bronx:Shared room-Manhattan:Private room                 -0.613982707
## Brooklyn:Shared room-Manhattan:Private room              -0.729180374
## Manhattan:Shared room-Manhattan:Private room             -0.262945955
## Queens:Shared room-Manhattan:Private room                -0.692291060
## Staten Island:Shared room-Manhattan:Private room          0.535226761
## Staten Island:Private room-Queens:Private room            0.002603636
## Bronx:Shared room-Queens:Private room                    -0.199314717
## Brooklyn:Shared room-Queens:Private room                 -0.313149396
## Manhattan:Shared room-Queens:Private room                 0.153332720
## Queens:Shared room-Queens:Private room                   -0.276844951
## Staten Island:Shared room-Queens:Private room             0.949294916
## Bronx:Shared room-Staten Island:Private room             -0.065803358
## Brooklyn:Shared room-Staten Island:Private room          -0.153620842
## Manhattan:Shared room-Staten Island:Private room          0.316153401
## Queens:Shared room-Staten Island:Private room            -0.126687602
## Staten Island:Shared room-Staten Island:Private room      1.066831335
## Brooklyn:Shared room-Bronx:Shared room                    0.276070897
## Manhattan:Shared room-Bronx:Shared room                   0.748319119
## Queens:Shared room-Bronx:Shared room                      0.293890075
## Staten Island:Shared room-Bronx:Shared room               1.414573208
## Manhattan:Shared room-Brooklyn:Shared room                0.591010571
## Queens:Shared room-Brooklyn:Shared room                   0.151710089
## Staten Island:Shared room-Brooklyn:Shared room            1.357179533
## Queens:Shared room-Manhattan:Shared room                 -0.328931986
## Staten Island:Shared room-Manhattan:Shared room           0.880860619
## Staten Island:Shared room-Queens:Shared room              1.356947324
##                                                              p adj
## Brooklyn:Entire home/apt-Bronx:Entire home/apt           0.0000000
## Manhattan:Entire home/apt-Bronx:Entire home/apt          0.0000000
## Queens:Entire home/apt-Bronx:Entire home/apt             0.0000000
## Staten Island:Entire home/apt-Bronx:Entire home/apt      0.9999351
## Bronx:Private room-Bronx:Entire home/apt                 0.0000000
## Brooklyn:Private room-Bronx:Entire home/apt              0.0000000
## Manhattan:Private room-Bronx:Entire home/apt             0.0000003
## Queens:Private room-Bronx:Entire home/apt                0.0000000
## Staten Island:Private room-Bronx:Entire home/apt         0.0000000
## Bronx:Shared room-Bronx:Entire home/apt                  0.0000000
## Brooklyn:Shared room-Bronx:Entire home/apt               0.0000000
## Manhattan:Shared room-Bronx:Entire home/apt              0.0000000
## Queens:Shared room-Bronx:Entire home/apt                 0.0000000
## Staten Island:Shared room-Bronx:Entire home/apt          0.9334310
## Manhattan:Entire home/apt-Brooklyn:Entire home/apt       0.0000000
## Queens:Entire home/apt-Brooklyn:Entire home/apt          0.0000000
## Staten Island:Entire home/apt-Brooklyn:Entire home/apt   0.0000000
## Bronx:Private room-Brooklyn:Entire home/apt              0.0000000
## Brooklyn:Private room-Brooklyn:Entire home/apt           0.0000000
## Manhattan:Private room-Brooklyn:Entire home/apt          0.0000000
## Queens:Private room-Brooklyn:Entire home/apt             0.0000000
## Staten Island:Private room-Brooklyn:Entire home/apt      0.0000000
## Bronx:Shared room-Brooklyn:Entire home/apt               0.0000000
## Brooklyn:Shared room-Brooklyn:Entire home/apt            0.0000000
## Manhattan:Shared room-Brooklyn:Entire home/apt           0.0000000
## Queens:Shared room-Brooklyn:Entire home/apt              0.0000000
## Staten Island:Shared room-Brooklyn:Entire home/apt       0.1425436
## Queens:Entire home/apt-Manhattan:Entire home/apt         0.0000000
## Staten Island:Entire home/apt-Manhattan:Entire home/apt  0.0000000
## Bronx:Private room-Manhattan:Entire home/apt             0.0000000
## Brooklyn:Private room-Manhattan:Entire home/apt          0.0000000
## Manhattan:Private room-Manhattan:Entire home/apt         0.0000000
## Queens:Private room-Manhattan:Entire home/apt            0.0000000
## Staten Island:Private room-Manhattan:Entire home/apt     0.0000000
## Bronx:Shared room-Manhattan:Entire home/apt              0.0000000
## Brooklyn:Shared room-Manhattan:Entire home/apt           0.0000000
## Manhattan:Shared room-Manhattan:Entire home/apt          0.0000000
## Queens:Shared room-Manhattan:Entire home/apt             0.0000000
## Staten Island:Shared room-Manhattan:Entire home/apt      0.0059751
## Staten Island:Entire home/apt-Queens:Entire home/apt     0.0186669
## Bronx:Private room-Queens:Entire home/apt                0.0000000
## Brooklyn:Private room-Queens:Entire home/apt             0.0000000
## Manhattan:Private room-Queens:Entire home/apt            0.0000000
## Queens:Private room-Queens:Entire home/apt               0.0000000
## Staten Island:Private room-Queens:Entire home/apt        0.0000000
## Bronx:Shared room-Queens:Entire home/apt                 0.0000000
## Brooklyn:Shared room-Queens:Entire home/apt              0.0000000
## Manhattan:Shared room-Queens:Entire home/apt             0.0000000
## Queens:Shared room-Queens:Entire home/apt                0.0000000
## Staten Island:Shared room-Queens:Entire home/apt         0.5055156
## Bronx:Private room-Staten Island:Entire home/apt         0.0000000
## Brooklyn:Private room-Staten Island:Entire home/apt      0.0000000
## Manhattan:Private room-Staten Island:Entire home/apt     0.0000169
## Queens:Private room-Staten Island:Entire home/apt        0.0000000
## Staten Island:Private room-Staten Island:Entire home/apt 0.0000000
## Bronx:Shared room-Staten Island:Entire home/apt          0.0000000
## Brooklyn:Shared room-Staten Island:Entire home/apt       0.0000000
## Manhattan:Shared room-Staten Island:Entire home/apt      0.0000000
## Queens:Shared room-Staten Island:Entire home/apt         0.0000000
## Staten Island:Shared room-Staten Island:Entire home/apt  0.8810147
## Brooklyn:Private room-Bronx:Private room                 0.0000000
## Manhattan:Private room-Bronx:Private room                0.0000000
## Queens:Private room-Bronx:Private room                   0.0000056
## Staten Island:Private room-Bronx:Private room            1.0000000
## Bronx:Shared room-Bronx:Private room                     0.0004030
## Brooklyn:Shared room-Bronx:Private room                  0.0000000
## Manhattan:Shared room-Bronx:Private room                 0.0000001
## Queens:Shared room-Bronx:Private room                    0.0000000
## Staten Island:Shared room-Bronx:Private room             0.9985718
## Manhattan:Private room-Brooklyn:Private room             0.0000000
## Queens:Private room-Brooklyn:Private room                0.0000000
## Staten Island:Private room-Brooklyn:Private room         0.0000003
## Bronx:Shared room-Brooklyn:Private room                  0.0000000
## Brooklyn:Shared room-Brooklyn:Private room               0.0000000
## Manhattan:Shared room-Brooklyn:Private room              0.9999999
## Queens:Shared room-Brooklyn:Private room                 0.0000000
## Staten Island:Shared room-Brooklyn:Private room          1.0000000
## Queens:Private room-Manhattan:Private room               0.0000000
## Staten Island:Private room-Manhattan:Private room        0.0000000
## Bronx:Shared room-Manhattan:Private room                 0.0000000
## Brooklyn:Shared room-Manhattan:Private room              0.0000000
## Manhattan:Shared room-Manhattan:Private room             0.0000000
## Queens:Shared room-Manhattan:Private room                0.0000000
## Staten Island:Shared room-Manhattan:Private room         0.9989793
## Staten Island:Private room-Queens:Private room           0.0637218
## Bronx:Shared room-Queens:Private room                    0.0000000
## Brooklyn:Shared room-Queens:Private room                 0.0000000
## Manhattan:Shared room-Queens:Private room                0.1616622
## Queens:Shared room-Queens:Private room                   0.0000000
## Staten Island:Shared room-Queens:Private room            0.9999971
## Bronx:Shared room-Staten Island:Private room             0.0019014
## Brooklyn:Shared room-Staten Island:Private room          0.0000000
## Manhattan:Shared room-Staten Island:Private room         0.0003984
## Queens:Shared room-Staten Island:Private room            0.0000002
## Staten Island:Shared room-Staten Island:Private room     0.9984808
## Brooklyn:Shared room-Bronx:Shared room                   1.0000000
## Manhattan:Shared room-Bronx:Shared room                  0.0000000
## Queens:Shared room-Bronx:Shared room                     1.0000000
## Staten Island:Shared room-Bronx:Shared room              0.4936656
## Manhattan:Shared room-Brooklyn:Shared room               0.0000000
## Queens:Shared room-Brooklyn:Shared room                  1.0000000
## Staten Island:Shared room-Brooklyn:Shared room           0.5208647
## Queens:Shared room-Manhattan:Shared room                 0.0000000
## Staten Island:Shared room-Manhattan:Shared room          1.0000000
## Staten Island:Shared room-Queens:Shared room             0.5448749
plot(TukeyHSD(nyc.model.fit.log,"neighbourhood_group:room_type", conf.level = .95))

Back Transformation

  • To keep the data easily interpretable we have moved our nyc.anova.diff results into a data frame and are now going to back transform the diff and upper and lower confidence interval results.
#nyc.anova.log.diff2 = tidy(nyc.anova.log.diff)
#colnames(nyc.anova.log.diff2)[3] <- "diff"
#invisible(view(nyc.anova.log.diff2))

#nyc.anova.log.diffdf <- nyc.anova.log.diff2[nyc.anova.log.diff2$adj.p.value <0.05,]
#invisible(yc.anova.log.diffdf)

#ConfInt_Diff_Backlog <- yc.anova.log.diffdf %>% mutate(Tdiff = exp(diff))
#ConfInt_Diff_Backlog <- ConfInt_Diff_Backlog %>% mutate(Tlow = exp(conf.low))
#ConfInt_Diff_Backlog <- ConfInt_Diff_Backlog %>% mutate(Thigh = exp(conf.high))

#ConfInt_Diff_Backlog <- select(ConfInt_Diff_Backlog, -c("diff", "conf.low", "conf.high"))
#ConfInt_Diff_Backlog <- ConfInt_Diff_Backlog[order(-ConfInt_Diff_Backlog$Tdiff),]
#ConfInt_Diff_Backlog